from django.db import models

class Object(models.Model):
    name = models.CharField(max_length=200)
    
    def __unicode__(self):
        return self.name
    
class ObjectField(models.Model):
    name = models.CharField(max_length=200)
    object = models.ForeignKey(Object)
    SINGLETXT = 'ST'
    MULTITXT = 'MT'
    INTEGER = 'IN'
    DATE = 'DA'
    LIST = 'LI'
    FIELD_TYPES = (
        (SINGLETXT, 'Single-line text'),
        (MULTITXT, 'Multi-line text'),
        (INTEGER, 'Integer'),
        (DATE, 'Date'),
        (LIST, 'List'),
    )
    type = models.CharField(max_length=2,
                            choices=FIELD_TYPES)
    
    def __unicode__(self):
        return self.name
    
class FieldOption(models.Model):
    name = models.CharField(max_length=200)
    field = models.ForeignKey(ObjectField)
    
    def __unicode__(self):
        return self.name
    
class ObjectForm(models.Model):
    name = models.CharField(max_length=200)
    object = models.ForeignKey(Object)
    
    def __unicode__(self):
        return self.name
    
class FormFieldMapping(models.Model):
    field = models.ForeignKey(ObjectField)
    form = models.ForeignKey(ObjectForm)
    
    def __unicode__(self):
        return self.name
    
    
class ObjectList(models.Model):
    name = models.CharField(max_length=200)
    object = models.ForeignKey(Object)
    fields = models.ManyToManyField(ObjectField)
    
    def __unicode__(self):
        return self.name
    
class Entity(models.Model):
    pass